import { JueJin } from './01. 掘金';
import { SegmentFault } from './02. 思否';
import { CSDN } from './03. CSDN';
import { Cnblogs } from './04. 博客园';
import { Fandom } from './05. Fandom';
import { Bing } from './06. Bing';
import { ZhiHu } from './07. 知乎';
import { DM3 } from './08. 3DM';
import { BaiduTieba } from './09. 百度贴吧';
import { BaiJiaHao } from './10. 百家号';
import { BaiduJinYan } from './11. 百度经验';
import { JianShu } from './12. 简书';
import { Jb51 } from './13. 脚本之家';
import { BaiduZhidao } from './14. 百度知道';
import { PoJie52 } from './15. 吾爱破解';
import { CTO51 } from './16. 51CTO';

const scripts = [
    JueJin, SegmentFault, CSDN, Cnblogs, Fandom, Bing, ZhiHu, DM3, 
    BaiduTieba, BaiJiaHao, BaiduJinYan, JianShu, Jb51, BaiduZhidao,
    PoJie52, CTO51
];

const { hostname, pathname } = window.location;

// 找到匹配的脚本
const script = scripts.find((item) => {
    if (Array.isArray(item.hostname) && item.hostname.length > 0) {
        return item.hostname.includes(hostname);
    } else {
        return item.hostname === hostname;
    }
});

// 执行脚本
if (script) new script()?.main(pathname);